Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for defaults #44

Merged
merged 7 commits into from
Oct 6, 2022
Merged

Add support for defaults #44

merged 7 commits into from
Oct 6, 2022

Conversation

ams9198
Copy link
Contributor

@ams9198 ams9198 commented Oct 5, 2022

Changes:

  • Tracks created loans on the LoanFactory
  • Tracks valid LoanFactories on the ServiceConfiguration
  • Combined, this allows the pool to properly validate that an address corresponds to a valid Valyria loan associated with the pool
  • Implements defaultLoan on the Pool, callable by the PM only while the pool is Active
  • The default adjusts activeLoanPrincipals according to the defaulted loan principal
  • The default transitions the Loan to a defaulted state

@ams9198 ams9198 marked this pull request as ready for review October 5, 2022 22:56
function defaultLoan(address loan)
external
onlyManager
atState(IPoolLifeCycleState.Active)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely correct, but I was torn whether we want it to be enforced, or leave it to the PM's discretion if something gets into a weird state (only way that it could would be a bug, but still).

@@ -219,13 +224,31 @@ contract Pool is IPool, ERC20 {
function fundLoan(address addr) external onlyManager {
ILoan loan = ILoan(addr);
loan.fund();
_accountings.activeLoanPrincipals += loan.principal();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be overwritten by the loan funding work, but the accounting in the default overflows without it, so I added it in

/**
* @dev Mapping of created loans
*/
mapping(address => bool) private _isLoan;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling this one out -- I can see an argument for this to instead live on the ServiceConfiguration, perhaps in a larger mapping keyed off of the loanFactory address.

This would map loanFactoryAddress => createdLoanAddress => bool, or something similar.

This might be slightly more testable, but perhaps overloads the Config contract. Curious if anyone has thoughts!

/**
* @dev Holds a reference to valid LoanFactories
*/
mapping(address => bool) public isLoanFactory;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See other comment re: LoanFactory mapping

Copy link
Contributor

@venables venables left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ams9198 ams9198 merged commit d4d1f6b into circlefin:master Oct 6, 2022
@ams9198 ams9198 deleted the defaults branch October 6, 2022 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants